#!/usr/bin/env node

console.log('开始timer1');
let timer1 = setInterval(loop1,500);
let timer2,count=1;

setTimeout(()=>{
    console.log('timer1结束')
    clearInterval(timer1);

    console.log('timer2开始')
    timer2=setInterval(loop2,500)
},5000);

function loop1(){
    console.log('timer1循环')
}

function loop2(){
    console.log('timer2循环')

    if(count++ >= 5){
        count = 0;
        console.log('timer2结束');
        global.clearInterval(timer2);
    }
}